{include file="public/header296" /}
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list">
  <div class="layui-form-item">
    <label class="layui-form-label">名称</label>
    <div class="layui-input-inline">
      <input type="text" lay-verify="required" name="name" value="{$data.name|default=''}" autocomplete="on" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">顶级分类</label>
    {notempty name="data['category_list']"}
    <div class="layui-input-inline">
      <select name="top_id"  lay-filter="top_id" lay-verify="required">
        <option value="0">顶级分类</option>
        {notempty name="data.top_id"}
          {volist name="data['category_list']" id="vo"}
          <option value="{$vo.id}" {notempty name="data.top_id"}{eq name="data.top_id" value="$vo.id"}selected{/eq}{/notempty}>{$vo.name}</option>
          {/volist}
        {else /}
          {volist name="data['category_list']" id="vo"}
          <option value="{$vo.id}" {notempty name="data.parent_id"}{eq name="data.parent_id" value="$vo.id"}selected{/eq}{/notempty}>{$vo.name}</option>
          {/volist}
        {/notempty}
      </select>
    </div>
    {/notempty}
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">岗位分类</label>
    <div class="layui-input-block" id="parent_id">
      {notempty name="data.category_list_child"}
        {volist name="data.category_list_child" id="vvo"}
          {if $data.top_id == 0}
            <input type="radio" name="parent_id" value="{$vvo.id}" title="{$vvo.name}" {eq name="data.id" value="$vvo.id"}checked{/eq}>
          {else /}
            <input type="radio" name="parent_id" value="{$vvo.id}" title="{$vvo.name}" {eq name="data.parent_id" value="$vvo.id"}checked{/eq}>
          {/if}
        {/volist}
      {/notempty}
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">排序id</label>
    <div class="layui-input-inline">
      <input type="text" name="sort" {notempty name="data.sort"}value="{$data.sort}"{else /}value="{:sort_id('job_category')}"{/notempty} class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">岗位级别</label>
    <div class="layui-input-block">
      {notempty name="$data.level"}
        <input type="radio" name="level" value="1" title="一级" disabled />
        <input type="radio" name="level" value="{$data.level}" title="二级" {eq name="data.level" value="2"}checked{/eq}>
        <input type="radio" name="level" value="{$data.level}" title="三级" {eq name="data.level" value="3"}checked{/eq}>
      {else /}
        <input type="radio" name="level" value="1" title="一级" />
        <input type="radio" name="level" value="2" title="二级" />
        <input type="radio" name="level" value="3" title="三级" />
      {/notempty}
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">热招岗位</label>
    <div class="layui-input-inline">
      <input type="checkbox" name="is_hot" lay-skin="switch" lay-filter="switchHot" lay-text="热门|非热门" {notempty name="data.is_hot"}{eq name="data.is_hot" value="1"}checked{/eq}{else/}{eq name="data.is_hot|default=''" value=""}{/eq}{/notempty} />
    </div>
  </div>
  {notempty name="$data.create_time"}
  <div class="layui-form-item">
    <label class="layui-form-label">最近更新</label>
    <div class="layui-input-block">
      <input type="text" class="layui-input" value="{$data.create_time|date='Y-m-d H:i:s'}" disabled="" />
    </div>
  </div>
  {/notempty}
  <div class="layui-form-item layui-hide">
    <input type="hidden" name="id" id="id" value="{$data.id|default=''}" />
    <input type="button" lay-submit lay-filter="Lay-app-form-edit" id="Lay-app-form-edit" value="编辑">
  </div>
</div>
<script>
  layui.use(['layer','form'], function(){
    var $ = layui.$
            , form = layui.form;

  form.on('select(top_id)',function(obj){
    var top_id = obj.value;
    $.ajax({
      url:"{:url('job/getJobCategory')}",
      type: "POST",
      dataType: "JSON",
      data: {top_id: top_id},
      success:function(data){
        var proHtml = '';
        for(var o in data){
          proHtml += '<input type="radio" name="parent_id" value="' + data[o].id +  '" title="'+ data[o].name +'">';
        }
        $('#parent_id').html(proHtml);
        form.render();
      },
      error:function(){
        alert("error");
      }
    })
  });
})
</script>
{include file="public/footer" /}